-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom decider #51
Conversation
sheriff.go
Outdated
@@ -10,8 +10,18 @@ import ( | |||
"github.com/hashicorp/go-version" | |||
) | |||
|
|||
// A Decider is a function that decides whether a field should be marshalled or not. | |||
// If it returns true, the field will be marshalled, otherwise it will be skipped. | |||
type Decider func(field reflect.StructField) (bool, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not convinced by the name! Very happy for recommendations here!
Looks like a great addition! I'll think a bit about the name - it's not a bad name but I feel there might be a better option as well. Maybe something along the lines of IncludeProperty/Field but I don't think it's better. |
1 similar comment
ChatGPT suggested the following alternatives:
Not sure. Thinking some more about it. Your opinion? 😄 |
Ah - the hardest thing in programming! Naming things! In your Readme you have this
So maybe |
Indeed! 😄 Maybe |
Perfect: 8dd1cf6 |
Amazing - thank you! |
An idea! Easier to demonstrate via a PR!
We use date based versioning instead of semantic versioning in our application. As such the default
since
/until
don't work for us.This PR adds the ability to overwrite the "decider" with a custom one. This allows any custom logic to be written to decide which fields should be included/excluded.
If a "decider" option is not provided then the existing logic will be used - as such this is a non-breaking change.